package com.zhang.modules.file.rep;

import com.zhang.common.jpa.rep.BaseRep;
import com.zhang.modules.file.entity.CosFileInfo;
import com.zhang.modules.file.entity.dto.CosFileInfoDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface CosFileRep extends BaseRep<CosFileInfo, String> {
    @Query("select c from CosFileInfo c where c.bucketName = ?1 and c.objectKey = ?2")
    CosFileInfo isExists(String bucketName, String objectKey);

    @Query("select new com.zhang.modules.file.entity.dto.CosFileInfoDto (c) from CosFileInfo c where c.objectKey like ?1  order by c.createTime")
    Page<CosFileInfoDto> findByObjectKeyLike(String objectKey, Pageable pageable);


    @Query("select new com.zhang.modules.file.entity.dto.CosFileInfoDto (c) from CosFileInfo c  order by c.createTime")
    Page<CosFileInfoDto> findDtos(Pageable pageable);






}
